/**
 * 用户相关API类型定义
 */

import type { BaseStats, BaseUserInfo, TimestampInfo } from './common'

// 用户信息响应
export interface UserProfileRespVO extends BaseUserInfo, TimestampInfo {
  username: string
  email?: string
  mobile?: string
  gender?: number
  birthday?: string
  status: number
  loginDate?: string
  loginIp?: string
  // 阅读统计
  readingStats?: UserReadingStats
}

// 用户阅读统计
export interface UserReadingStats extends BaseStats {
  totalReadBooks: number
  totalPunchDays: number
  currentStreakDays: number
  totalReadingTime: number // 总阅读时长（分钟）
  averageReadingTime: number // 平均阅读时长（分钟）
  favoriteCategory?: string
  readingLevel: number
}

// 用户设置响应（与后端匹配）
export interface UserSettingsRespVO {
  id: number
  userId: number
  readingMode: string // image-图片模式, text-文字模式
  autoTurnPage: boolean
  turnPageDelay: number // 翻页延迟（秒）
  autoPlayAudio: boolean
  autoTurnAfterAudio: boolean
  autoReadNext: boolean
}

// 用户设置更新请求（与后端匹配）
export interface UserSettingsUpdateReqVO {
  readingMode?: string
  autoTurnPage?: boolean
  turnPageDelay?: number
  autoPlayAudio?: boolean
  autoTurnAfterAudio?: boolean
  autoReadNext?: boolean
}

// 用户信息更新请求
export interface UserProfileUpdateReqVO {
  nickname?: string
  avatar?: string
  gender?: number
  birthday?: string
  email?: string
}

// 用户登录请求
export interface UserLoginReqVO {
  username: string
  password: string
  captchaVerification?: string
}

// 用户登录响应
export interface UserLoginRespVO {
  userId: number
  accessToken: string
  refreshToken: string
  expiresTime: number
  userInfo: UserProfileRespVO
}

// 用户注册请求
export interface UserRegisterReqVO {
  username: string
  password: string
  confirmPassword: string
  mobile?: string
  email?: string
  captchaVerification: string
}

// 密码修改请求
export interface PasswordChangeReqVO {
  oldPassword: string
  newPassword: string
  confirmPassword: string
}

// 手机号绑定请求
export interface MobileBindReqVO {
  mobile: string
  code: string
}

// 邮箱绑定请求
export interface EmailBindReqVO {
  email: string
  code: string
}

// 用户关注信息
export interface UserFollowInfo extends BaseUserInfo {
  isFollowing: boolean
  isMutual: boolean
  followTime?: string
  followerCount: number
  followingCount: number
}

// 用户关注列表响应
export interface UserFollowListRespVO {
  userId: number
  targetUserId: number
  targetUser: BaseUserInfo
  followTime: string
  isMutual: boolean
}

// 用户粉丝列表响应
export interface UserFollowerListRespVO {
  userId: number
  followerUserId: number
  followerUser: BaseUserInfo
  followTime: string
  isMutual: boolean
}

// 用户关注统计
export interface UserFollowStats {
  followingCount: number
  followerCount: number
  mutualCount: number
}

// 用户成就信息
export interface UserAchievement {
  id: number
  name: string
  description: string
  icon: string
  condition: string
  isUnlocked: boolean
  unlockTime?: string
  progress?: number
  maxProgress?: number
}

// 用户等级信息
export interface UserLevel {
  currentLevel: number
  currentExp: number
  nextLevelExp: number
  levelName: string
  levelIcon: string
  privileges: string[]
}

// 用户活动记录
export interface UserActivity {
  id: number
  type: string // reading-阅读, punch-打卡, plan-计划, follow-关注
  title: string
  description: string
  targetId?: number
  targetType?: string
  createTime: string
}

// 用户偏好设置
export interface UserPreferences {
  favoriteCategories: number[]
  preferredLanguage: string
  readingGoal: number // 每日阅读目标（分钟）
  difficultyLevel: string // beginner-初级, intermediate-中级, advanced-高级
  interests: string[]
}

// 用户反馈
export interface UserFeedback {
  id: number
  type: string // bug-问题反馈, suggestion-建议, praise-表扬
  title: string
  content: string
  images?: string[]
  contact?: string
  status: string // pending-待处理, processing-处理中, resolved-已解决
  reply?: string
  createTime: string
  updateTime?: string
}

// 用户反馈提交请求
export interface UserFeedbackCreateReqVO {
  type: string
  title: string
  content: string
  images?: string[]
  contact?: string
}
